﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace ParkManagement
{
    /// <summary>
    /// 车辆控制器
    /// </summary>
    [Authorize]
    [RemoteService]
    [Area("commonManagement")]
    [Route("api/parkManagement/cars")]
    public class CarController : AbpController, ICarAppService
    {
        private readonly ICarAppService _carAppService;

        public CarController(
            ICarAppService carAppService)
        {
            _carAppService = carAppService;
        }

        // 添加
        [HttpPost]
        [Route("")]
        public Task<ActionResponse> CreateAsync(CreateCarDto input)
        {
            return _carAppService.CreateAsync(input);
        }

        // 更新
        [HttpPut]
        [Route("")]
        public Task<ActionResponse> UpdateAsync(UpdateCarDto input)
        {
            return _carAppService.UpdateAsync(input);
        }

        // 我的
        [HttpGet]
        [Route("my")]
        public Task<ListResponse<CarDto>> MyAsync(PagedListRequest request)
        {
            return _carAppService.MyAsync(request);
        }

        // 删除
        [HttpDelete]
        [Route("{id:int}")]
        public Task<ActionResponse> DeleteAsync(int id)
        {
            return _carAppService.DeleteAsync(id);
        }
    }
}